home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: Utrecht.NL.net!news
- From: E.H.Terwiel@inter.NL.net (E.H. Terwiel (Erik))
- Subject: Re: ? pointer to array of pointers
- X-Nntp-Posting-Host: utr99-167.utrecht.nl.net
- Message-ID: <DLLMKD.GEy@inter.NL.net>
- Sender: news@inter.NL.net (News at newsutr)
- Organization: NLnet
- X-Newsreader: Forte Free Agent 1.0.82
- References: <4e0ckd$ht1@badger.wmin.ac.uk>
- Date: Mon, 22 Jan 1996 20:04:17 GMT
-
- kruppd@westminster.ac.uk (Declan Kruppa) wrote:
-
- >I am trying to use some routines in "Numerical Recipies in C"
- >The book gives code for a function char **matrix which allocates
- >memory for a
- >a pointer to an array of ponters. If I call this function with
- >a=matrix(1,10,1,10) it seems to work ok and I can access the elements of
- >the array using a[i][j] .
- >However I would like to be able to step through the array using pointer
- >notation such as *p++ or **p++ . What would be the notation to step through the 10000 elements sequentily using pointer notation.
-
- >Also I would like to write the pointer to a file stream like:
- >File *fp
- >fp=fopen("FILE","wb");
- >fwrite(a,1,10000,fp);
-
- >but when I read back the file it is not at all what I expect.
- >I think that *p is a ponter to the rows in the matrix so I would expect it to
- >step through every 10th element in the array. I don't know how to access
- >sequential elements a[1][1], a[1][2] etc using pointer arithmetic or how to
- >write it to a file.
- >Any help appreciated.
-
- >Declan Kruppa
- >University of Westminster
-
- Watch out for Num recip.
-
- The code is not very good, obvious translation from FORTRAN.
- Also it is said that the authors are not very knowledgeable on the
- various subjects.
-
- Also: arrays start at index 1 instead of 0 !!!!!
-
- Erik
-
-